Fix various compiler warnings with the 64bit mingw build
authorChristoph Reiter <reiter.christoph@gmail.com>
Tue, 2 Jun 2020 18:41:38 +0000 (20:41 +0200)
committerChristoph Reiter <reiter.christoph@gmail.com>
Sun, 14 Jun 2020 18:02:36 +0000 (20:02 +0200)
Use better matching format modifiers/specifiers, initialise some things
which in theory wont be written to because of getters using g_return_if_fail(),
a cast, and gsize as input for malloc because gsize!=glong on 64bit Windows.

gdk/win32/gdkclipdrop-win32.c
gdk/win32/gdkdevicemanager-win32.c
gdk/win32/gdkdrop-win32.c
gdk/win32/gdkevents-win32.c
gdk/win32/gdkhdataoutputstream-win32.c
gtk/gtkiconview.c

index 74eb2500a8e0ed414cd85429b5ec3a68b9461632..0755876d653dc42e139b14e8db6d03002c523d71 100644 (file)
@@ -889,10 +889,12 @@ grab_data_from_hdata (GdkWin32ClipboardThreadRetrieve *retr,
 
   if (data == NULL)
     {
+      gchar *length_str = g_strdup_printf ("%" G_GSIZE_FORMAT, length);
       send_response (retr->parent.item_type,
                      retr->parent.opaque_task,
                      g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
-                                  _("Cannot get clipboard data. Failed to allocate %lu bytes to store the data."), length));
+                                  _("Cannot get clipboard data. Failed to allocate %s bytes to store the data."), length_str));
+      g_free (length_str);
       GlobalUnlock (hdata);
       return NULL;
     }
@@ -1536,7 +1538,7 @@ gdk_win32_clipdrop_init (GdkWin32Clipdrop *win32_clipdrop)
   thread_wakeup_message = RegisterWindowMessage ("GDK_WORKER_THREAD_WEAKEUP");
 
   user32 = LoadLibrary ("user32.dll");
-  win32_clipdrop->GetUpdatedClipboardFormats = GetProcAddress (user32, "GetUpdatedClipboardFormats");
+  win32_clipdrop->GetUpdatedClipboardFormats = (GetUpdatedClipboardFormatsFunc) GetProcAddress (user32, "GetUpdatedClipboardFormats");
   FreeLibrary (user32);
 
   atoms = g_array_sized_new (FALSE, TRUE, sizeof (const char *), GDK_WIN32_ATOM_INDEX_LAST);
@@ -2193,7 +2195,7 @@ transmute_utf8_string_to_cf_text (const guchar    *data,
 {
   glong rlen;
   GError *err = NULL;
-  glong size;
+  gsize size;
   gint i;
   char *strptr, *p;
   wchar_t *wcptr;
index a55864c89576cff9566a848ff62a505ec84700b4..74d9aa18470966334c407c47242f7596590c41ac 100644 (file)
@@ -883,7 +883,7 @@ gdk_input_other_event (GdkDisplay *display,
   guint translated_buttons, button_diff, button_mask;
 
   GdkEventType event_type;
-  int event_button;
+  int event_button = 0;
   GdkModifierType event_state;
   double event_x, event_y;
   double *axes;
index ff6035dc4fdb3fedb473a61bfaa10838155d14d3..8d4af3b42099912f3462035a68390696b578ffe2 100644 (file)
@@ -1225,8 +1225,10 @@ grab_data_from_hdata (GTask  *task,
 
   if (data == NULL)
     {
+      gchar *length_str = g_strdup_printf ("%" G_GSIZE_FORMAT, length);
       g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
-                               _("Cannot get DnD data. Failed to allocate %lu bytes to store the data."), length);
+                               _("Cannot get DnD data. Failed to allocate %s bytes to store the data."), length_str);
+      g_free (length_str);
       GlobalUnlock (hdata);
       return NULL;
     }
index 409f03dfd267b59144febe2623bd5817c7348402..377f4afbdfb2021109e18c0136ad7a9abb280efb 100644 (file)
@@ -287,7 +287,7 @@ _gdk_win32_surface_procedure (HWND   hwnd,
 {
   LRESULT retval;
 
-  GDK_NOTE (EVENTS, g_print ("%s%*s%s %p %#x %#lx",
+  GDK_NOTE (EVENTS, g_print ("%s%*s%s %p %#" G_GINTPTR_MODIFIER "x %#" G_GINTPTR_MODIFIER "x",
                             (debug_indent > 0 ? "\n" : ""),
                             debug_indent, "",
                             _gdk_win32_message_to_string (message), hwnd,
@@ -1876,7 +1876,7 @@ handle_wm_sysmenu (GdkSurface *window, MSG *msg, gint *ret_valp)
    * FALSE later) or set *ret_valp to 0 and return TRUE.
    */
   tmp_style = style | additional_styles;
-  GDK_NOTE (EVENTS, g_print (" Handling WM_SYSMENU: style 0x%lx -> 0x%lx\n", style, tmp_style));
+  GDK_NOTE (EVENTS, g_print (" Handling WM_SYSMENU: style 0x%" G_GINTPTR_MODIFIER "x -> 0x%" G_GINTPTR_MODIFIER "x\n", style, tmp_style));
   impl->have_temp_styles = TRUE;
   impl->temp_styles = additional_styles;
   SetWindowLongPtr (msg->hwnd, GWL_STYLE, tmp_style);
@@ -1886,7 +1886,7 @@ handle_wm_sysmenu (GdkSurface *window, MSG *msg, gint *ret_valp)
   tmp_style = GetWindowLongPtr (msg->hwnd, GWL_STYLE);
   style = tmp_style & ~additional_styles;
 
-  GDK_NOTE (EVENTS, g_print (" Handling WM_SYSMENU: style 0x%lx <- 0x%lx\n", style, tmp_style));
+  GDK_NOTE (EVENTS, g_print (" Handling WM_SYSMENU: style 0x%" G_GINTPTR_MODIFIER "x <- 0x%" G_GINTPTR_MODIFIER "x\n", style, tmp_style));
   SetWindowLongPtr (msg->hwnd, GWL_STYLE, style);
   impl->have_temp_styles = FALSE;
 
index aa10ab415f1cd7dc712c78cc763000efb42bb826..95a57981f05c4d89b8a7c9b76fe7194a96d71609 100644 (file)
@@ -129,7 +129,7 @@ gdk_win32_hdata_output_stream_write (GOutputStream  *output_stream,
   gssize result = write_stream (stream, priv, buffer, count, error);
 
   if (result != -1)
-    GDK_NOTE(SELECTION, g_printerr ("CLIPBOARD: wrote %zd bytes, %u total now\n",
+    GDK_NOTE(SELECTION, g_printerr ("CLIPBOARD: wrote %zd bytes, %" G_GSIZE_FORMAT " total now\n",
                                     result, priv->data_length));
 
   return result;
@@ -158,7 +158,7 @@ gdk_win32_hdata_output_stream_write_async (GOutputStream        *output_stream,
 
   if (result != -1)
     {
-      GDK_NOTE (SELECTION, g_printerr ("CLIPBOARD async wrote %zd bytes, %u total now\n",
+      GDK_NOTE (SELECTION, g_printerr ("CLIPBOARD async wrote %zd bytes, %" G_GSIZE_FORMAT " total now\n",
                                        result, priv->data_length));
       g_task_return_int (task, result);
     }
index 1cff081002f84690b2f78510ea8fcfd577940a33..2fc1123c07922357f74d637cc6999ba280db668b 100644 (file)
@@ -1560,7 +1560,7 @@ gtk_icon_view_measure (GtkWidget *widget,
   GtkIconViewPrivate *priv = icon_view->priv;
   GtkOrientation other_orientation = orientation == GTK_ORIENTATION_HORIZONTAL ?
                                      GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL;
-  int item_min, item_nat, items, item_size, n_items;
+  int item_min, item_nat, items = 0, item_size = 0, n_items;
 
   if (gtk_icon_view_is_empty (icon_view))
     {
@@ -2715,7 +2715,7 @@ gtk_icon_view_layout (GtkIconView *icon_view)
   GtkIconViewPrivate *priv = icon_view->priv;
   GtkWidget *widget = GTK_WIDGET (icon_view);
   GList *items;
-  gint item_width; /* this doesn't include item_padding */
+  gint item_width = 0; /* this doesn't include item_padding */
   gint n_columns, n_rows, n_items;
   gint col, row;
   GtkRequestedSize *sizes;